home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 13710 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.2 KB  |  41 lines

  1. Path: holly.ACNS.ColoState.EDU!not-for-mail
  2. From: corbyh@holly.ACNS.ColoState.EDU (Corby S. Hudnall)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: 'delete' dos not work !!!! (for me...)
  5. Date: 26 Mar 1996 19:35:10 -0700
  6. Organization: Colorado State University, Fort Collins, CO  80523
  7. Message-ID: <4ja9gu$4arm@holly.ACNS.ColoState.EDU>
  8. References: <ROLLET.96Mar18215549@oriole.DMI.USherb.CA> <4iq7ee$enb@pegasus.odyssee.net>
  9. NNTP-Posting-Host: holly.acns.colostate.edu
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. : If you alocate using [], use [] to free.....
  13.  
  14. : int *i = new int [256];
  15.  
  16. : free [] i;
  17.   ^^^^
  18.  
  19. not quite right.  if you new'd memory, you must use delete.  if you 
  20. malloc'd memory, you must use free.  You can not "free" new'd space or 
  21. "delete" malloc'd space.  Use:
  22.  
  23. delete [] i;
  24.  
  25. in your code instead.
  26.  
  27. // ------------ BEGIN SIGNATURE ---------------
  28. #include <iostream.h>
  29. void main(void)
  30. {
  31.   cout << "\aName:\tCorby S. Hudnall\n"
  32.        << "School:\tColorado State University\n"
  33.        << "\tDepartement of Computer Science\n"
  34.        << "EMail:\thudnall@CS.ColoState.EDU\n"
  35.        << "URL:\thttp://WWW.CS.ColoState.EDU/~hudnall\n";
  36. }
  37. // ------------ END SIGNATURE -----------------
  38.  
  39.  
  40.  
  41.